﻿#region Opis pliku
//-----------------------------------------------------------------------------
// ExplosionEmiter.cs
// Autor: Jan Fraś
// 30.10.2012
//-----------------------------------------------------------------------------
#endregion


#region Using..

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

#endregion

namespace pogra
{
    /// <summary>
    /// emiter eksplozji
    /// </summary>
    class ExplosionEmitter : Emitter
    {

        public ExplosionEmitter(Vector2 Position) :
            base(Position, null) {life = TimeSpan.FromMilliseconds(20); }


        protected override void GenerateParticles()
        {
            maxParticles = 200;
            // generacja nowych cząsteczek

            while (particleList.Count < maxParticles && life > TimeSpan.Zero)
            {
                Color color = Color.Gold;
                double lifeSeconds = Rand.nextFloat(0,1.5);
                double velocity = Rand.nextFloat(10, 300) ;
                double rotation = Rand.nextFloat(0, Math.PI * 2 );
                Vector2 tmp = new Vector2(Rand.nextFloat(-10, 10), Rand.nextFloat(-10, 10));

                particleList.AddLast(new ExplosionParticle(Position + tmp, (float)velocity, (float)rotation, TimeSpan.FromSeconds(lifeSeconds)));

                //for (int i = 0; i < 3; i++)
                {
                    lifeSeconds = Rand.nextFloat(0, 1);
                    velocity = Rand.nextFloat(10, 100);
                    rotation = Rand.nextFloat(0, Math.PI * 2);
                    particleList.AddLast(new ExplosionParticle2(Position + tmp, (float)velocity, (float)rotation, TimeSpan.FromSeconds(lifeSeconds)));
                }
            }
        }
    }
}
